
#ifndef	__DISPLAY_H__
#define	__DISPLAY_H__

#include "board.h"

#define LED_WORK_PIN			(0)	/* P1.0 */
#define	LED_WORK_PORT			(1)
#define	LED_ERROR_PIN			(1)	/* P1.1 */
#define	LED_ERROR_PORT		(1)
#define	LED_RX_PIN				(10) /* P0.10 */
#define	LED_RX_PORT				(0)
#define	LED_TX_PIN				(11)	/* P0.11 */
#define	LED_TX_PORT				(0)

#define	SEGMENT_A					(1<<18)
#define	SEGMENT_B					(1<<19)
#define	SEGMENT_C					(1<<20)
#define	SEGMENT_D					(1<<22)
#define	SEGMENT_E					(1<<23)
#define	SEGMENT_F					(1<<24)
#define	SEGMENT_G					(1<<25)
#define	SEGMENT_H					(1<<26)
#define	SEGMENT_CS1				(1<<28)
#define	SEGMENT_CS2				(1<<29)

#define	SEGMENT_PORT			(1)

#define ADDRESS_0_PIN			(14)
#define	ADDRESS_0_PORT		(1)
#define ADDRESS_1_PIN			(15)
#define	ADDRESS_1_PORT		(1)
#define ADDRESS_2_PIN			(29)
#define	ADDRESS_2_PORT		(4)
#define ADDRESS_3_PIN			(28)
#define	ADDRESS_3_PORT		(4)
#define ADDRESS_4_PIN			(6)
#define	ADDRESS_4_PORT		(0)
#define ADDRESS_5_PIN			(7)
#define	ADDRESS_5_PORT		(0)

#define	CFG_BAUDRATE_PIN	(8)
#define	CFG_BAUDRATE_PORT	(0)
#define CFG_MODE_PIN			(9)
#define	CFG_MODE_PORT			(0)

#define	SEGMENT_DISPLAY_TIME_MS	3		/*< 定义数码管的显示延时时间，过长会出闪烁 过短会只有1只数码管亮 */

#define Delay_ms	SysTick_Delay_ms	/*< 如果自定义毫秒延时函数，显示延时使用自定义的函数。否则使用默认延时函数 */

extern uint32_t flash_address_cfg;

struct Pin{
	uint8_t port;
	uint8_t pin;
};

typedef struct Pin LED_TypeDef;
extern LED_TypeDef LedWork,LedError,LedTx,LedRx;

typedef struct Pin CFG_TypeDef;
extern CFG_TypeDef CfgBaudrate,CfgMode;

void LED_On(LED_TypeDef led);
void LED_Off (LED_TypeDef led);
void LED_Toggle (LED_TypeDef led);

bool Get_Cfg_Pin_Value(CFG_TypeDef cfg);

void Display_Init(void);
void Display_Address(uint8_t value);
//void segment_off (void);
uint32_t Get_Address(void);

#endif
